package com.haiyi.software.mycontrols;

import com.haiyi.software.app.R;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class MyControlListTitle extends RelativeLayout {

	private TextView textView;

	private ImageView imageView;

	public MyControlListTitle(Context context, AttributeSet attrs) {

		super(context, attrs);
		// TODO 自动生成的构造函数存根
		if (isInEditMode()) {
			return;
		}
		View view = LayoutInflater.from(context).inflate(
				R.layout.control_dl_title, this, true);

		textView = (TextView) view.findViewById(R.id.textview_dd_title);
		imageView = (ImageView) view.findViewById(R.id.img_dd_bar);

		TypedArray typedArray = context.obtainStyledAttributes(attrs,
				R.styleable.TextView_TitleBar);
		CharSequence text = typedArray
				.getText(R.styleable.TextView_TitleBar_txttext);

		if (text != null) {
			textView.setText(text);
		}

		int textColor = typedArray.getColor(
				R.styleable.TextView_TitleBar_txttextcolor, 0xFFFFFFFF);

		textView.setTextColor(textColor);

		float textSize = typedArray.getDimension(
				R.styleable.TextView_TitleBar_txtfontsize, 14);

		textView.setTextSize(textSize);

		int imgBackgroundColor = typedArray.getColor(
				R.styleable.TextView_TitleBar_imgbackgroundcolor, 0xFFFFFFFF);

		imageView.setBackgroundColor(imgBackgroundColor);

		typedArray.recycle();
	}

	public void setText(String text) {

		this.textView.setText(text);

	}
}
